from datetime import datetime

# Create your models here.
from django.db import models
from django.contrib.auth.models import AbstractUser


# 用户
# 继承 Django 自带的User
class UserProfile(AbstractUser):
    name = models.CharField(max_length=30, null=True, blank=True, verbose_name="姓名")  # 可为空
    birthday = models.DateField(null=True, blank=True, verbose_name="出生年月")  # 可为空
    gender = models.CharField(max_length=6, choices=(("male", "男"), ("female", "女"),), default="female", verbose_name="性别")
    mobile = models.CharField(max_length=11, verbose_name="电话号码")
    email = models.CharField(max_length=100, null=True, blank=True, verbose_name="邮箱")  # 可为空

    class Meta:
        verbose_name = "用户"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username


# 短信验证码
class VerifyCode(models.Model):
    code = models.CharField(max_length=10, verbose_name="验证码")
    mobile = models.CharField(max_length=11, verbose_name="电话号码")
    add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间")  # 这里不能加 ()， 如果加了的话，就会用编译的时间作为当前时间

    class Meta:
        verbose_name = "短信验证码"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code
